Skip to content

feat: high resolution and nested fractional enhancement#373

Open
leakonvalinka wants to merge 5 commits intoopen-feature:mainfrom
open-feature-forking:feat/high-resolution-fractional
Open

feat: high resolution and nested fractional enhancement#373
leakonvalinka wants to merge 5 commits intoopen-feature:mainfrom
open-feature-forking:feat/high-resolution-fractional

Conversation

@leakonvalinka
Copy link
Member

@leakonvalinka leakonvalinka commented Mar 23, 2026

This PR

  • adds this new feature

Related Issues

#360 and #359

Notes

Follow-up Tasks

Todo: remove fractional-v2 and fractional-nested tags from RPC tests

How to test

Signed-off-by: Lea Konvalinka <lea.konvalinka@dynatrace.com>
Signed-off-by: Lea Konvalinka <lea.konvalinka@dynatrace.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the fractional evaluation mechanism within the flagd provider. It focuses on improving the precision and reliability of fractional flag assignments by modernizing the underlying hashing and bucketing algorithms. The changes aim to enhance the accuracy and robustness of fractional flag evaluations, resolving a previously identified issue.

Highlights

  • Refactored Fractional Bucketing Logic: The core logic for fractional evaluation has been refactored into a new helper function, _resolve_bucket_by, to improve modularity and clarity.
  • Updated Hashing Algorithm: The hashing mechanism for fractional evaluation now uses an unsigned 32-bit MurmurHash3, enhancing precision and distribution.
  • Implemented High-Resolution Bucketing: A new high-resolution bucketing mechanism has been introduced, utilizing bit-shifting operations instead of percentage-based calculations, which significantly improves the accuracy of fractional assignments.
  • Added Weight Validation: A check has been added to ensure that the total fractional weight does not exceed MaxInt32 (2,147,483,647), preventing potential overflow issues.
  • Expanded End-to-End Test Coverage: New end-to-end test filters (~fractional-v1, ~fractional-v2, ~fractional-nested) have been enabled across various test configurations to validate the new fractional evaluation feature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@leakonvalinka leakonvalinka changed the title Feat/high resolution fractional feat: high resolution and nested fractional enhancement Mar 23, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors and improves the fractional evaluation logic to support high-resolution bucketing. The changes include extracting logic into a helper function, using unsigned 32-bit hashes for better distribution, and adopting a more precise integer-based calculation for bucketing. The test configurations are also updated to reflect these changes. My review identifies a minor opportunity for improving maintainability by replacing a magic number with a named constant.

Signed-off-by: lea konvalinka <lea.konvalinka@dynatrace.com>
Signed-off-by: Lea Konvalinka <lea.konvalinka@dynatrace.com>
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.27%. Comparing base (0ecd1d4) to head (e839b82).

Files with missing lines Patch % Lines
...rib/provider/flagd/resolvers/process/custom_ops.py 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #373      +/-   ##
==========================================
- Coverage   95.57%   95.27%   -0.30%     
==========================================
  Files          30       16      -14     
  Lines        1491      911     -580     
==========================================
- Hits         1425      868     -557     
+ Misses         66       43      -23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Lea Konvalinka <lea.konvalinka@dynatrace.com>
@leakonvalinka
Copy link
Member Author

There's still 1 failing test, but I'm not sure how to fix it because I don't know what exactly it should be testing in the first place. It's the invalid-fractional-weights.json case of the test_json_logic_parse_errors test, which has valid weights but previously invalid variant types.

@leakonvalinka leakonvalinka marked this pull request as ready for review March 23, 2026 15:10
@leakonvalinka leakonvalinka requested review from a team as code owners March 23, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants